(deftemplate persoana (slot nume)(slot sex) (slot parinte) (slot partener))

(assert (persoana (nume Petru)(sex M)(parinte null)(partener Veta)))
(assert (persoana (nume Veta)(sex F)(parinte null)(partener Petru)))
(assert (persoana (nume Teodor)(sex M)(parinte null)(partener Alberta)))
(assert (persoana (nume Alberta)(sex F)(parinte null)(partener Teodor)))
(assert (persoana (nume Hans)(sex M)(parinte null)(partener Armando)))
(assert (persoana (nume Armando)(sex M)(parinte null)(partener Hans)))
(assert (persoana (nume Miguel)(sex M)(parinte Veta)(partener null)))
(assert (persoana (nume George)(sex M)(parinte Veta)(partener Maria)))
(assert (persoana (nume Maria)(sex F)(parinte Alberta)(partener George)))
(assert (persoana (nume Vasilica)(sex F)(parinte Alberta)(partener Mirela)))
(assert (persoana (nume Mirela)(sex F)(parinte null)(partener Vasilica)))
(assert (persoana (nume Nemo)(sex M)(parinte Armando)(partener null)))
(assert (persoana (nume Ionel)(sex M)(parinte Maria)(partener null)))
(assert (persoana (nume Oana)(sex F)(parinte Maria)(partener null)))
(assert (persoana (nume Vanesa)(sex F)(parinte Mirela)(partener null)))
;afisare mame
(defrule mama1
    (persoana (nume ?nc)(parinte ?np))
    (persoana (nume ?np)(sex F))
    => (printout t "Persoana " ?nc " are mama " ?np crlf)
 )
;afisare mame la lezbiene
(defrule mama2
    (persoana (nume ?nc)(parinte ?np))
    (persoana (nume ?np)(partener ?npp))
    (persoana (nume ?npp) (sex F))
    => (printout t "Persoana " ?nc " are mama " ?npp crlf)
 )
;afisare sotia unei persoane
(defrule sotie
  	(persoana (nume ?nc)(partener ?np))
    (persoana (nume ?np) (sex F))
    => (printout t "Persoana " ?nc " are sotia " ?np crlf)  
)
;afisare bunica unei persoane
(defrule bunica
	(persoana (nume ?nc)(parinte ?np))
    (persoana (nume ?np)(parinte ?npp))
    (persoana (nume ?npp)(sex F))
    => (printout t "Persoana " ?nc " are bunica " ?npp crlf)        
)
;afisare bunicul unei persoane
(defrule bunic
	(persoana (nume ?nc)(parinte ?np))
    (persoana (nume ?np)(parinte ?npp))
    (persoana (nume ?npp)(sex M))
    => (printout t "Persoana " ?nc " are bunicul " ?npp crlf)        
)

(facts)
(run)